// MsgQueue.cpp: implementation of the CMsgQueue class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "AskTSAPI.h"
#include "MsgQueue.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CMsgQueue::CMsgQueue()
{

}

CMsgQueue::~CMsgQueue()
{

}

CString CMsgQueue::Pop()
{
	m_CriticalSection.Lock();
	CString sMsg;
	sMsg = m_MsgList.RemoveHead();
	m_CriticalSection.Unlock();
	return sMsg;
}

void   CMsgQueue::Push(CString sMsg)
{
	m_CriticalSection.Lock();
	m_MsgList.AddTail(sMsg);
	m_CriticalSection.Unlock();
}
BOOL   CMsgQueue::IsEmpty()
{
	return m_MsgList.IsEmpty();
}
int   CMsgQueue::GetCount()
{
	return m_MsgList.GetCount();
}

BOOL CMsgQueue::Clear()
{
	try
	{
		m_MsgList.RemoveAll();
	}
	catch (CMemoryException e)
	{
		return FALSE;
	}
	//catch (CException e)
	//{
	//	return FALSE;
	//}
	return TRUE;
   
}